//
//  CalendarController.m
//  WOFishingBoat
//
//  Created by 郑逸凯 on 2019/1/8.
//  Copyright © 2019年 郑逸凯. All rights reserved.
//

#import "CalendarController.h"
#import "YACalendarView.h"

@interface CalendarController ()<YACalendarViewDelegate>

@property (nonatomic,strong)YACalendarView *calendarView;
@property (nonatomic,strong)UILabel *photoNumberLaebl;
@property (nonatomic,strong)UIButton *confirmButton;
@property (nonatomic,strong)NSDate *selectDate;

@end

@implementation CalendarController
#pragma mark - Life Cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupSubviews];
    [self performLayout];
    
}

#pragma mark - Public Methods
#pragma mark - Responder Actions

- (void)confirmedAction {
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectDayConfirmed:)]) {
        [self.delegate selectDayConfirmed:self.selectDate];
    }
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - Delegates

- (void)selectNewDay:(NSDate *)date photoNumber:(NSInteger)number calendarView:(YACalendarView *)calendarView {
    self.selectDate = date;
    self.photoNumberLaebl.text = [NSString stringWithFormat:@"%li张",number];
}

#pragma mark - Request



#pragma mark - Private Methods
- (void)setupSubviews {
    self.navigationItem.title = @"日期";
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView: self.confirmButton];
    self.navigationItem.rightBarButtonItem = rightItem;
    [self.view addSubview:self.calendarView];
    [self.view addSubview:self.photoNumberLaebl];
//    self.calendarView.frame = CGRectMake(10, Height_TopBar, SCREEN_WIDTH - 20, 335);
//    CGFloat calendarViewBottom = CGRectGetMaxY(self.calendarView.frame);
    UIView *view = [[UIView alloc] init];
    view.frame = CGRectMake(20,429,SCREEN_WIDTH - 40,0.5);
    view.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1.0];
    [self.view addSubview:view];
    
    UILabel *countLabel = [[UILabel alloc] init];
    countLabel.frame = CGRectMake(20,451.5,28,11.5);
    countLabel.numberOfLines = 0;
    countLabel.textColor = RGB16(0x666666);
    countLabel.text = @"数量";
    countLabel.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:countLabel];
    
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(20,508.5,300,11.5);
    label.textColor = RGB16(0x666666);
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:12];
    label.text = @"温馨提示：有圆点标识的有图片记录哦";
    [self.view addSubview:label];
    
    self.photoNumberLaebl.frame = CGRectMake(21,472.5,60,16.5);
    
}

- (void)performLayout {
   
  
    
}



#pragma mark - Setters and Getters
- (YACalendarView *)calendarView {
    if (!_calendarView) {
        YACalendarView *calendarView = [[YACalendarView alloc] initWithFrame:CGRectMake(10, Height_TopBar , [UIScreen mainScreen].bounds.size.width-20, 335 + 40)];
        calendarView.delegate = self;
        _calendarView = calendarView;
        
    }
    return _calendarView;
}

- (UILabel *)photoNumberLaebl {
    if (!_photoNumberLaebl) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = RGB16(0x333333);
        label.font = [UIFont systemFontOfSize:18];
        _photoNumberLaebl = label;
    }
    return _photoNumberLaebl;
}

- (UIButton *)confirmButton {
    if (!_confirmButton) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"确定" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button setTitleColor:RGB16(0x2988fc) forState:UIControlStateNormal];
        _confirmButton = button;
        [_confirmButton addTarget:self action:@selector(confirmedAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _confirmButton;
}

#pragma mark - Helper




@end
